home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / s_to_z / tpack / invoice.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  4.0 KB  |  193 lines

  1. unit Invoice;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, ExtCtrls, Toolbar
  8. , UserInfo, Menus;
  9.  
  10. type
  11.   TInvoiceForm = class(TForm)
  12.     Memo1: TMemo;
  13.     Memo2: TMemo;
  14.     Memo3: TMemo;
  15.     Label1: TLabel;
  16.     MessagePanel2: TMessagePanel;
  17.     Label2: TLabel;
  18.     Label3: TLabel;
  19.     Memo4: TMemo;
  20.     Image1: TImage;
  21.     Memo5: TMemo;
  22.     Button1: TButton;
  23.     Label4: TLabel;
  24.     EdRight1: TEdRight;
  25.     PopupMenu1: TPopupMenu;
  26.     Print1: TMenuItem;
  27.     Close1: TMenuItem;
  28.     procedure Button1Click(Sender: TObject);
  29.     procedure FormActivate(Sender: TObject);
  30.     procedure FormDeactivate(Sender: TObject);
  31.     procedure Memo2Enter(Sender: TObject);
  32.     procedure Memo2Exit(Sender: TObject);
  33.     procedure EdRight1Enter(Sender: TObject);
  34.     procedure EdRight1Exit(Sender: TObject);
  35.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  36.     procedure Close1Click(Sender: TObject);
  37.     procedure Print1Click(Sender: TObject);
  38.   private
  39.     { Private declarations }
  40.     fOnHint: TNotifyevent;
  41.     procedure OnHint(Sender: TObject);
  42.   public
  43.     { Public declarations }
  44.   end;
  45.  
  46.   TInvoice = class(TDialogShell)
  47.   public
  48.     procedure Execute; Override;
  49.   end;
  50.  
  51. implementation
  52.  
  53. {$R *.DFM}
  54.  
  55. const
  56.   InvoiceForm: TInvoiceForm= nil;
  57.  
  58.  
  59. procedure TInvoiceForm.Close1Click(Sender: TObject);
  60. begin
  61.   close;
  62. end;
  63.  
  64. procedure TInvoiceForm.Print1Click(Sender: TObject);
  65. begin
  66.   Button1.Click;
  67. end;
  68.  
  69. procedure TInvoice.Execute;
  70. begin
  71.   if InvoiceForm=nil then begin
  72.     InvoiceForm:=TInvoiceForm.Create(Application);
  73.     with InvoiceForm do begin
  74.       OnClose:=FormClose;
  75.       Show;
  76.       end
  77.     end
  78.   else
  79.     InvoiceForm.BringToFront;
  80. end;
  81.  
  82.  
  83. procedure TInvoiceForm.FormClose(Sender: TObject;
  84.   var Action: TCloseAction);
  85. begin
  86.   AcTion:=caFree;
  87.   InvoiceForm:=nil;
  88. end;
  89.  
  90.  
  91. procedure TInvoiceForm.Button1Click(Sender: TObject);
  92. var
  93.   i,n,h,w:integer;
  94. begin
  95.   Button1.Visible:=False;
  96.   Caption:='Printing '+Caption;
  97.   Enabled:=False;
  98.   h:=Height;
  99.   w:=width;
  100.   Width:=w+200;
  101.   n:=ControlCount-1;
  102.   for i:=0 to n do
  103.     Controls[i].Left:=Controls[i].Left+100;
  104.   Height:=h+450;
  105.   with TMemo.Create(Self) do begin
  106.     Parent:=Self;
  107.     BorderStyle:=bsNone;
  108.     Height:=350;
  109.     Align:=AlBottom;
  110.     Clear;
  111.     with lines do begin
  112.       Add('');
  113.       Add('');
  114.       Add('');
  115.       Add('RETURN ADDRESS');
  116.       Add('');
  117.       Add(Memo2.Text);
  118.       Add('');
  119.       Add('');
  120.       Add('');
  121.       Add('SEND TO');
  122.       Add('');
  123.       Add(Memo1.Text);
  124.       end;
  125.     Print;
  126.     Free;
  127.     end;
  128.   Height:=h;
  129.   for i:=0 to n do
  130.     Controls[i].Left:=Controls[i].Left-100;
  131.   Width:=w;
  132.   Enabled:=True;
  133.   Caption:=Copy(Caption,10,255);
  134.   Button1.Visible:=True;
  135. end;
  136.  
  137. procedure TInvoiceForm.FormActivate(Sender: TObject);
  138. begin
  139.   fOnHint:=Application.OnHint;
  140.   Application.OnHint:=OnHint;
  141. end;
  142.  
  143. procedure TInvoiceForm.FormDeactivate(Sender: TObject);
  144. begin
  145.   Application.OnHint:=fOnHint;
  146. end;
  147.  
  148. procedure TInvoiceForm.OnHint(Sender: TObject);
  149. begin
  150.   with Button1 do
  151.     if Application.Hint='' then
  152.       Caption:='Click to Print the '+Self.Caption
  153.     else
  154.       Caption:=Application.Hint+';  Click to Print';
  155. end;
  156.  
  157. procedure TInvoiceForm.Memo2Enter(Sender: TObject);
  158. begin
  159.   tMemo(Sender).BorderStyle:=bsSingle;
  160. end;
  161.  
  162. procedure TInvoiceForm.Memo2Exit(Sender: TObject);
  163. begin
  164.   tMemo(Sender).BorderStyle:=bsNone;
  165. end;
  166.  
  167. procedure TInvoiceForm.EdRight1Enter(Sender: TObject);
  168. begin
  169.   EdRight1.Font.Style:= EdRight1.Font.Style-[fsUnderline];
  170. end;
  171.  
  172. procedure TInvoiceForm.EdRight1Exit(Sender: TObject);
  173. begin
  174.   EdRight1.Font.Style:= EdRight1.Font.Style+[fsUnderline]
  175. end;
  176.  
  177.  
  178. {-----------------------------------------------------------------------------------------}
  179.  
  180. {
  181. const
  182.   Initialize: Boolean= True;
  183.  
  184. initialization
  185.   if Initialize then
  186.     with TInvoice.Create(Application) do try
  187.       dec(Initialize);
  188.       Execute;
  189.     finally
  190.       Free;
  191.       end;   {}
  192. end.
  193.